# 去掉无关列 data = data.drop(data.columns[[0,2]], axis=1)
1
data.head()
sentiment
content
0
empty
@tiffanylue i know i was listenin to bad habi…
1
sadness
Layin n bed with a headache ughhhh…waitin o…
2
sadness
Funeral ceremony…gloomy friday…
3
enthusiasm
wants to hang out with friends SOON!
4
neutral
@dannycastillo We want to trade with someone w…
1
dataset = data.as_matrix()
/usr/local/lib/python3.5/dist-packages/ipykernel_launcher.py:1: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.
"""Entry point for launching an IPython kernel.
1
dataset.shape
(40000, 2)
1
features = dataset[:,1]
1
features[123]
'@poinktoinkdoink He died. Wait, what about Magic Jack? I just read it.'
1
target = dataset[:,0]
1 2 3 4
# 使用LabelEncoder对不同的情感target进行编码 from sklearn.preprocessing import LabelEncoder le = LabelEncoder() target_processed = le.fit_transform(target)